﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GestionePolveriLib.BL;

namespace GestionePolveriImporter
{
    public class LottoComparer : IEqualityComparer<Lotto>
    {
        // Products are equal if their names and product numbers are equal. 
        public bool Equals(Lotto x, Lotto y)
        {
            //Check whether the compared objects reference the same data. 
            if (Object.ReferenceEquals(x, y)) return true;

            //Check whether any of the compared objects is null. 
            if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
                return false;

            //Check whether the products' properties are equal. 
            return x.CodLotto == y.CodLotto;
        }

        // If Equals() returns true for a pair of objects  
        // then GetHashCode() must return the same value for these objects. 

        public int GetHashCode(Lotto lotto)
        {
            //Check whether the object is null 
            if (Object.ReferenceEquals(lotto, null)) return 0;

            //Get hash code for the Code field. 
            int hashProductCode = lotto.CodLotto.GetHashCode();

            //Calculate the hash code for the product. 
            return hashProductCode;
        }

    }
}
